import request from '@/utils/request';

// 圈子列表
export async function communityList(data) {
  const res = await request.post('/communityList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function updateCommunityStatus(data) {
  const res = await request.post('/updateCommunityStatus', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function updateSort(data) {
  const res = await request.post('/updateSort', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function addRollMessage(data) {
  const res = await request.post('/message/addRollMessage', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}

export async function joinCommunityList(data) {
  const res = await request.post('/joinCommunityList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function rollMessageList(data) {
  const res = await request.post('/message/rollMessageList', data);
  if (res.data.code === 0) {
    return res.data.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function delRollMessage(data) {
  const res = await request.post('message/delRollMessage', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function addCommunity(data) {
  const res = await request.post('/addCommunity', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
export async function editCommunity(data) {
  const res = await request.post('/editCommunity', data);
  if (res.data.code === 0) {
    return res.data;
  }
  return Promise.reject(new Error(res.data.message));
}
